package com.huabo.system.service.impl;


import com.hbfk.entity.DealUserToken;
import com.hbfk.entity.TblStaffUtil;
import com.hbfk.util.PageInfo;
import com.huabo.system.mysql.entity.FindMySql;
import com.huabo.system.mysql.entity.TblyypriceMySql;
import com.huabo.system.mysql.mapper.TblyypriceMySqlMapper;
import com.huabo.system.oracle.entity.Find;
import com.huabo.system.oracle.entity.Tblyyprice;
import com.huabo.system.oracle.mapper.TblyypriceMapper;
import com.huabo.system.service.TblyypriceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblyypriceServiceImpl implements TblyypriceService {

    @Resource
    private TblyypriceMapper tblyypriceMapper;

    @Resource
    private TblyypriceMySqlMapper tblyypriceMySqlMapper;

    @Override
    public Map<String, Object> findListPage(Find find, String token, String staffId, Integer pageNumber, Integer pageSize) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        try {
            TblStaffUtil staff = DealUserToken.parseUserToken(token);
            BigDecimal orgid = staff.getCurrentOrg().getOrgid();
            PageInfo<Tblyyprice> pageInfo = new PageInfo<Tblyyprice>();
            pageInfo.setCurrentPage(pageNumber);
            pageInfo.setPageSize(pageSize);
            pageInfo.setTlist(tblyypriceMapper.selectListByPageInfo(pageInfo, find, orgid));
            pageInfo.setTotalRecord(tblyypriceMapper.selectCountByPageInfo(pageInfo, find, orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "数据访问成功");
            resultMap.put("data", pageInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> findMySqlListPage(Find find, String token, String staffId, Integer pageNumber, Integer pageSize) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        try {
            TblStaffUtil staff = DealUserToken.parseUserToken(token);
            BigDecimal orgid = staff.getCurrentOrg().getOrgid();
            PageInfo<TblyypriceMySql> pageInfo = new PageInfo<TblyypriceMySql>();
            pageInfo.setCurrentPage(pageNumber);
            pageInfo.setPageSize(pageSize);
            pageInfo.setTlist(tblyypriceMySqlMapper.selectListByPageInfo(pageInfo, find, orgid));
            pageInfo.setTotalRecord(tblyypriceMySqlMapper.selectCountByPageInfo(pageInfo, find, orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "数据访问成功");
            resultMap.put("data", pageInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultMap;
    }


}
